#include <iostream>
#include <deque>

using namespace std;

const int N = 1e6;
int a[N];
int n, k;
int main()
{
	deque<int> q;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];

		while (q.size() && a[i] <= a[q.back()]) q.pop_back();
		q.push_back(i);
		if (i - q.front() + 1 > k)
			q.pop_front();
		if (i >= k) cout << a[q.front()] << endl;
	}
	return 0;
}